home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / SCRATTR.N < prev    next >
Text File  |  1995-11-08  |  13KB  |  420 lines

  1. Define DosColInitCreate() {
  2.     Print(`Define DosColInit() {
  3.     if (temp^init^col)
  4.         return;
  5.     temp^init^col = 1;
  6. `);
  7.     for (i = 0; i < argc; i += 1) {
  8.         if (i < 8)
  9.             Print(
  10. `    temp^bg^["`><argv[i]><`"] =
  11. `);
  12.         Print(
  13. `    temp^fg^["`><argv[i]><`"] = `><i><`;
  14.     temp^col^[`><i><`] = "`><argv[i]><`";
  15.  
  16. `); }
  17.     Print(`}
  18. `);
  19. }
  20. DosColInitCreate(black,
  21.                  blue,
  22.                  green,
  23.                  cyan,
  24.                  red,
  25.                  magenta,
  26.                  brown,
  27.                  light grey,
  28.                  dark grey,
  29.                  light blue,
  30.                  light green,
  31.                  light cyan,
  32.                  light red,
  33.                  light magenta,
  34.                  yellow,
  35.                  white)
  36. Define DosColFieldDefine(title, name, row, value)
  37. /*
  38.     generate the code to decode the attribute byte into
  39.     foreground and background, and to create the prompt
  40.     and the foreground and background combo boxes for one row
  41. */
  42. {
  43.     Print(
  44. `    `><name><`fg = temp^col^[StrToAscii(parm^screen^colour^`><value><`) % 16];
  45.     `><name><`bg = temp^col^[StrToAscii(parm^screen^colour^`><value><`) / 16];
  46.     SdPrompt(scr, `><row><`, 2, "`><title><`");
  47.     SdPrompt(scr, `><row><`,12, ":");
  48.     SdCombo(scr, "`><name><`fg",  1, `><row><`, 14, 18, 18, &`><name><`fg, "temp^fg^", , , , "Lowercase");
  49.     SdPrompt(scr, `><row><`,33, "on");
  50.     SdCombo(scr, "`><name><`bg",  1, `><row><`, 36, 16, 10,  &`><name><`bg, "temp^bg^", , , , "Lowercase");
  51. `);
  52. }
  53. Define DosColFieldValidate(name, value)
  54. /*
  55.     generates the code to validate the colour attribute variable
  56.     using the foreground and background components
  57. */
  58. {
  59.     Print(
  60.         `if (!temp^col^[temp^fg^[`><name><`fg]])
  61.             cursor = "`><name><`fg";
  62.         else if (!temp^col^[temp^bg^[`><name><`bg]])
  63.             cursor = "`><name><`bg";
  64.         else `);
  65. }
  66. Define DosColFieldUpdate(name, value)
  67. /*
  68.     generates the code to update the colour attribute variable
  69.     using the foreground and background components
  70. */
  71. {
  72.     Print(
  73. `        
  74.         parm^screen^colour^`><value><` = StrFromAscii(temp^bg^[`><name><`bg] * 16 + temp^fg^[`><name><`fg]);
  75. `);
  76. }
  77. Define DosColScreen(name, title)
  78. /*
  79.     generates the code for a DOS colour screen
  80. */
  81. {
  82.     rows = (argc - 2) / 3;
  83.  Print(
  84. `Define DosCol`><name><`() {
  85.     DosColInit();
  86.     scr = SdCreate(, -2, -2, `><rows + 4><`, 54, "`><title><`");
  87.  
  88. `);
  89.     for (row = 0; row < rows; row += 1) {
  90.         DosColFieldDefine(argv[2 + row * 3], 
  91.                           argv[3 + row * 3],
  92.                           row + 1,
  93.                           argv[4 + row * 3]);
  94. Print(`
  95. `);
  96.     }
  97. Print(
  98. `    SdButton(scr, "", 1,    `><rows + 2><`, 13, 10, "OK",     "", 1);
  99.     SdButton(scr, "", 1,    `><rows + 2><`, 30, 10, "Cancel", "", 2);
  100.     while ((cmd = SdEdit(scr, cursor)) == 1) {
  101.         SdUpdate(scr);
  102.         cursor = "";
  103.  
  104.         `);
  105.  
  106.     for (row = 0; row < rows; row += 1) {
  107.         DosColFieldValidate(argv[3 + row * 3],
  108.                           argv[4 + row * 3]);
  109.     }
  110. Print(
  111.         ` {};
  112.         if (cursor) {
  113.             MsgWait("DOS Colours", "Invalid colour");
  114.             continue;
  115.         }
  116.         temp^col^modded = 1;
  117. `);
  118.  
  119.     for (row = 0; row < rows; row += 1) {
  120.         DosColFieldUpdate(argv[3 + row * 3],
  121.                           argv[4 + row * 3]);
  122.     }
  123. Print(
  124. `
  125.         break;
  126.     }
  127.     SdDestroy(scr);
  128. }`);
  129. }
  130. If(0)
  131.     Following statements generate the code for the colour screens, 
  132.     one for area, second for prompt fields and so on.
  133. Endif
  134. DosColScreen(Area, Area Colours,
  135.             Original, o, area^orig,
  136.             Grey,     g, area^grey,
  137.             Focus,    f, area^focus,
  138.             Shadow,   s, area^shadow)
  139.  
  140. DosColScreen(Prompt, Prompt Colours,
  141.             Grey,       g, prompt^grey,
  142.             Enable,     e, prompt^enable,
  143.             Enable Hi,  eh, prompt^enable^hi)
  144.  
  145. DosColScreen(Field, Field Colours,
  146.             Grey,       g, field^grey,
  147.             Enable,     e, field^enable,
  148.             Enable Hi,  eh, field^enable^hi,
  149.             Focus,      f, field^focus,
  150.             Focus Hi,   fh, field^focus^hi)
  151.  
  152. DosColScreen(SelBox, Selection Box Colours,
  153.             Grey,       g, select^grey,
  154.             Enable,     e, select^enable,
  155.             Enable Hi,  eh, select^enable^hi,
  156.             Focus,      f, select^focus,
  157.             Focus Hi,   fh, select^focus^hi)
  158.  
  159. DosColScreen(Menu, Menu Colours,
  160.             Grey,       g, menu^grey,
  161.             Enable,     e, menu^enable,
  162.             Enable Hi,  eh, menu^enable^hi,
  163.             Focus,      f, menu^focus,
  164.             Focus Hi,   fh, menu^focus^hi)
  165.  
  166. Define DosCharInit()
  167. /*
  168.     generate the temp variables used for the char combo box
  169. */
  170. {
  171.     if (temp^init^ch)
  172.         return;
  173.     temp^init^ch = 1;
  174.  
  175.     for (i = 0; i < 256; i += 1)
  176.         temp^ch^[StrFromAscii(i)] = i;
  177. }
  178. Define DosCharFieldDefine(title, name, row, value)
  179. {
  180.     Print(
  181. `    `><name><`ch = parm^screen^char^`><value><`;
  182.     SdPrompt(scr, `><row><`, 7, "`><title><`");
  183.     SdPrompt(scr, `><row><`,23, ":");
  184.     SdCombo(scr, "`><name><`ch",  1, `><row><`, 25, 10, 22, &`><name><`ch, "temp^ch^");
  185. `);
  186. }
  187. Define DosCharFieldUpdate(name, value)
  188. {
  189.     Print(
  190. `        parm^screen^char^`><value><` = `><name><`ch;
  191. `);
  192. }
  193. Define DosCharScreen(name, title)
  194. {
  195.     rows = (argc - 2) / 3;
  196. Print(
  197. `Define DosChar`><name><`() {
  198.     DosCharInit();
  199.     scr = SdCreate(, -2, -2, `><rows + 4><`, 42, "`><title><`");
  200.  
  201. `);
  202.     for (row = 0; row < rows; row += 1) {
  203.         DosCharFieldDefine(argv[2 + row * 3], 
  204.                           argv[3 + row * 3],
  205.                           row + 1,
  206.                           argv[4 + row * 3]);
  207. Print(`
  208. `);
  209.     }
  210. Print(
  211. `    SdButton(scr, "", 1,    `><rows + 2><`, 8, 10, "OK",     "", 1);
  212.     SdButton(scr, "", 1,    `><rows + 2><`, 24, 10, "Cancel", "", 2);
  213.     if ((cmd = SdEdit(scr)) == 1) {
  214.         SdUpdate(scr);
  215.         temp^col^modded = 1;
  216.  
  217. `);
  218.  
  219.     for (row = 0; row < rows; row += 1) {
  220.         DosCharFieldUpdate(argv[3 + row * 3],
  221.                           argv[4 + row * 3]);
  222.     }
  223. Print(
  224. `
  225.     }
  226.     SdDestroy(scr);
  227. }`);
  228. }
  229. DosCharScreen(Area, Area Characters,
  230.             Original, o, area^orig,
  231.             Fill,     f, area^fill,
  232.             Close,    c, area^close)
  233.  
  234. DosCharScreen(Border, Border Characters,
  235.             Top Left,       a, area^tlc,
  236.             Top Right,      b, area^trc,
  237.             Top Horiz,      c, area^thl,
  238.             Left Vert,      d, area^lvl,
  239.             Right Vert,     e, area^rvl,
  240.             Bottom Left,    f, area^blc,
  241.             Bottom Right,   g, area^brc,
  242.             Bottom Horiz,   h, area^bhl)
  243.  
  244. DosCharScreen(BorderFocus, Focus Border Characters,
  245.             Top Left,       a, area^focus^tlc,
  246.             Top Right,      b, area^focus^trc,
  247.             Top Horiz,      c, area^focus^thl,
  248.             Left Vert,      d, area^focus^lvl,
  249.             Right Vert,     e, area^focus^rvl,
  250.             Bottom Left,    f, area^focus^blc,
  251.             Bottom Right,   g, area^focus^brc,
  252.             Bottom Horiz,   h, area^focus^bhl)
  253.  
  254. DosCharScreen(Button, Button Characters,
  255.             Default Left,   a,  button^def^l,
  256.             Default Right,  b,  button^def^r,
  257.             Default Fill,   c,  button^def^fill,
  258.             Left,           d,  button^l,
  259.             Right,          e,  button^r,
  260.             Fill,           f,  button^fill)
  261.  
  262. Define DosScreenAttr()
  263. /*
  264.     The main program
  265. */
  266. {
  267.     SymOpen("temp");
  268.     scr = SdCreate("DosColMenu", 3, 5, 10, 60, "DOS Screen Attributes");
  269.  
  270.     SdMenu(scr, "main", 1, "Colours",       "c", 120,
  271.                         1, "Characters",    "a", 121,
  272.                         1, "Misc",          "m", 122,
  273.                         1, "Restart",       "r", 123);
  274.  
  275.     SdPopup(scr, "col", 120, 1, "Area",             "a", 151,
  276.                              1, "Prompt",           "p", 152,
  277.                              1, "Field",            "f", 153,
  278.                              1, "Select Box",       "s", 154,
  279.                              1, "Menu",             "m", 155);
  280.  
  281.     SdPopup(scr, "ch", 121, 1, "Area",              "a", 171,
  282.                             1, "Border",            "b", 172,
  283.                             1, "Focus Border",      "f", 173,
  284.                             1, "Button",            "u", 174);
  285.  
  286.     SdPopup(scr, "misc", 122, 1, "Options",         "o", 161,
  287.                               1, "Jim's Pref",      "j", 162);
  288.  
  289.     temp^col^modded = 0;
  290.     while ((cmd = SdEdit(scr)) > 3) {
  291.         switch (cmd) {
  292.         case 123:
  293.             Signal("");
  294.         case 151:
  295.             DosColArea();
  296.             break;
  297.         case 152:
  298.             DosColPrompt();
  299.             break;
  300.         case 153:
  301.             DosColField();
  302.             break;
  303.         case 154:
  304.             DosColSelBox();
  305.             break;
  306.         case 155:
  307.             DosColMenu();
  308.             break;
  309.         case 161:
  310.             DosScreenOptions();
  311.             break;  
  312.         case 162:
  313.             if (MsgYesNo("DOS Screen Attributes",
  314.                          "Restore Jim's colour preferences ?")) {
  315.                 DosScreenJimsPref();
  316.                 MsgWait("DOS Screen Attributes", 
  317.                         "Jim's colour preferences restored");
  318.                 temp^col^modded = 1;
  319.             }
  320.             break;  
  321.         case 171:
  322.             DosCharArea();
  323.             break;
  324.         case 172:
  325.             DosCharBorder();
  326.             break;
  327.         case 173:
  328.             DosCharBorderFocus();
  329.             break;
  330.         case 174:
  331.             DosCharButton();
  332.             break;
  333.         }
  334.     }
  335.     SdDestroy(scr);
  336.     if (temp^col^modded)
  337.         Signal("Restarting system to initialize selected colours");
  338.     SymClose("temp");
  339. }
  340. Define DosScreenOptions() {
  341.     scr = SdCreate(, -2, -2, 5, 42, "Screen Options");
  342.  
  343.     SdCheck (scr, "", 1, 1, 7, 16, &parm^screen^option^area^shadow, "Shadow Areas", "s");
  344.  
  345.     SdButton(scr, "", 1,    3, 8, 10, "OK",     "", 1);
  346.     SdButton(scr, "", 1,    3, 24, 10, "Cancel", "", 2);
  347.     if ((cmd = SdEdit(scr)) == 1) {
  348.         SdUpdate(scr);
  349.         temp^col^modded = 1;
  350.     }
  351.     SdDestroy(scr);
  352. }
  353. Define DosScreenJimsPref() {                // sets to Jims preferences
  354.     pre = "parm^screen^char^area";
  355.     [pre]^orig          = "\xb2";           // fill block
  356.     [pre]^fill          = " ";
  357.     [pre]^close         = "\xfe";
  358.  
  359.     parm^screen^option^area^shadow  = "s";  // shadow areas
  360.  
  361.     pre = "parm^screen^char^area";
  362.     [pre]^focus^tlc     = "\xd5";           // border lines
  363.     [pre]^focus^trc     = "\xb8";
  364.     [pre]^focus^thl     = "\xcd";
  365.     [pre]^focus^lvl     = "\xb3";
  366.     [pre]^focus^rvl     = "\xb3";
  367.     [pre]^focus^blc     = "\xc0";
  368.     [pre]^focus^brc     = "\xd9";
  369.     [pre]^focus^bhl     = "\xc4";
  370.  
  371.     [pre]^tlc           = "\xda";
  372.     [pre]^trc           = "\xbf";
  373.     [pre]^thl           = "\xc4";
  374.     [pre]^lvl           = "\xb3";
  375.     [pre]^rvl           = "\xb3";
  376.     [pre]^blc           = "\xc0";
  377.     [pre]^brc           = "\xd9";
  378.     [pre]^bhl           = "\xc4";
  379.  
  380.     pre = "parm^screen^char^button";
  381.     [pre]^def^l         = "[";              // button chars the same
  382.     [pre]^def^r         = "]";
  383.     [pre]^def^fill      = " ";
  384.     [pre]^l             = "[";
  385.     [pre]^r             = "]";
  386.     [pre]^fill          = " ";
  387.  
  388.     pre = "parm^screen^colour^area";
  389.     [pre]^orig          = "\x70";       // area black on white
  390.     [pre]^grey          = "\x78";
  391.     [pre]^focus         = "\x70";
  392.     [pre]^shadow        = "\x08";
  393.  
  394.     pre = "parm^screen^colour^prompt";
  395.     [pre]^grey          = "\x78";
  396.     [pre]^enable        = "\x70";
  397.     [pre]^enable^hi     = "\x7f";
  398.  
  399.     pre = "parm^screen^colour^field";
  400.     [pre]^grey          = "\x78";   // field bright white on blue
  401.     [pre]^enable        = "\x17";
  402.     [pre]^enable^hi     = "\x1f";
  403.     [pre]^focus         = "\x1f";
  404.     [pre]^focus^hi      = "\x1f";
  405.  
  406.     pre = "parm^screen^colour^select";
  407.     [pre]^grey          = "\x78";   // select white on blue
  408.     [pre]^enable        = "\x17";
  409.     [pre]^enable^hi     = "\x71";
  410.     [pre]^focus         = "\x17";
  411.     [pre]^focus^hi      = "\x71";
  412.  
  413.     pre = "parm^screen^colour^menu";
  414.     [pre]^grey          = "\x18";   // menu white on blue
  415.     [pre]^enable        = "\x17";
  416.     [pre]^enable^hi     = "\x1f";
  417.     [pre]^focus         = "\x71";
  418.     [pre]^focus^hi      = "\x7f";
  419. }
  420.